<?php
/**
 * Created by PhpStorm.
 * User: qufan
 * Date: 2016/12/12 0012
 * Time: 1:29
 */

namespace Common\Model;


use Think\Model;

class RoleModel extends Model
{
    protected $_auto = array(
        array('platform',1),
    );

    public function update($data = null){
        $data = $this->token(false)->create($data);
        if (empty($data)){
            return false;
        }

        if (empty($data['role_id'])){
            $id = $this->add();
            if (!$id){
                $this->error = '新增角色出错';
                return false;
            }
            $data['role_id'] = $id;
        }else{
            $status = $this->save();
            if (false === $status){
                $this->error = '更新角色出错';
                return false;
            }
        }
        return $data;
    }



}